<?php
namespace app\wx\controller;
use think\facade\Request;
use app\wx\validate\AdminValidate;
use app\wx\service\AdminLoginService;
use JokerCode\JokerVerify;
use think\captcha\Captcha;

class AdminLogin
{
    /**
     * 获取验证码
     */
    public function verify()
    {
        // $id = time().mt_rand(100000,999999);
        // $result = JokerVerify::__init()->make($id);
        // $result['id'] = $id;
        // return success($result);
        // $id = time().mt_rand(100000,999999);
        // $c = new Captcha();
        // return $c->entry($id);
        //继承tp验证码
    }

    //验证
    public function yz()
    {
        // $id = Request::post('id/d','');
        // $x = Request::post('x/d','');
        // if(JokerVerify::check($id,$x))
        //     return success('验证成功');
        // return error('验证失败');
    }

    //登录
    public function login()
    {
        //接收参数
        $param = array(
            'number'     => Request::post('number/s',''),
            'pwd'        => Request::post('pwd/s',''),
            'request_ip' => Request::ip()
            // 'verify_id' => Request::post('verify_id/s',''), //验证码ID
            // 'verify_code' => Request::post('verify_code/s',''), //验证码值
        );
        $validate = new AdminValidate();
        if (!$validate->scene('login')->check($param))
            error($validate->getError());
        $data = AdminLoginService::login($param);
        return success($data, '登录成功');
    }
}